/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package findfirststring;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Mr.D
 */
public class Main {

    /**
     * @param args the command line arguments
     */    
    public static void main(String[] args) {
        // TODO code application logic here
        System.out.println(10<<2);
        String hexnum = "0123456789ABCDEF";
        String binarynum = "";
        String fullhex ="";
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Nhap chuoi so hex: ");
        try {
            String hex = br.readLine();
            for(int i = 0; i < hex.length(); i++){
                for(int j = 0; j < 16; j ++){
                    if(hex.toUpperCase().charAt(i) == hexnum.charAt(j)){
                        fullhex = "";
                        for(byte k = 0; k < 4 - Integer.toBinaryString(j).length(); k ++)
                            fullhex += "0";
                        fullhex += Integer.toBinaryString(j);
                        binarynum += fullhex;
                        break;
                    }
                }
            }
            System.out.println(binarynum);
            System.out.println("Vi tri dau tien cua chuoi 111 la: "+binarynum.indexOf("111"));
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
    }

}
